home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
c
/
flgzero.exe
/
FLGZERO.ASM
< prev
next >
Wrap
Assembly Source File
|
1991-09-16
|
3KB
|
69 lines
PAGE ,132 ; 80 for narrow printers
TITLE ZERO FLAGS ; Set display tab to 8 characters
COMMENT *
Given the base address of a flag word and the number of bits it contains,
this function will set all the bits in the flag word to zero (Note that it works
in byte increments) The program zeros nothing if no bits are defined, allowing
it to be used with a variable. It is not designed to work with negative bit counts.
Programmed By: A. L. Bender, M. D.
Bender Consulting
PO Box 8685
Woodcliff Lake, NJ 07675
Not copyright, freely in public domain.
Not responsible for your use or misuse of this program.
This program was tested with Microsoft c 5.1. It demonstrates how the bits
are stored in a word. The enclosed driver program shows how to call it and
how to test it. Assumes direction flag is set to FORWARD. (An ok MSC 5.1
Assumption)
The primary purpose of this program is instructional, you can hopefully learn
something about MASM 5.1 Programming from this, especially how to use the
higher level language interface. See Microsoft MASM 5.1 Update.
Note: This will not execute on an 8086/88 but requires at least an 80186 or V20
You can remove the .186 statement to get it going on the 8086/88 if you need to
The masm call line needs /Dmemmodel={SMALL|MEDIUM|COMPACT|LARGE} as the case
may be to write the proper code.
Example:
masm /Dmemmodel=SMALL /Mx flgzero,,,; Makes a small model flgzero
*
.186 ; Set processor required
IFDEF memmodel ; Did user define it?
% .MODEL memmodel,c ; Use user definition
ELSE
.MODEL LARGE, c ;If not told otherwise, make
ENDIF
.CODE ;Large Model C Program
flgzero PROC flagword:PTR BYTE, nrbits:WORD ; Prologue
MOV AX,nrbits ; Get Bit count
TEST AX,AX ; If bits are defined (Non Degenerative Case)
JZ @F ; don't get out
DEC AX ; Make count 0...7
IF @Cpu NE 0
SAR AX,3 ; Divide by 8 The easy way
ELSE
MOV CL,3
SAR AX,CL ; Divide by 8 the hard way
ENDIF
XOR CX,CX ; Prep CX for later
INC AX ; Insure fraction of byte is ok
XCHG CX,AX ; Copy Quotient of 8 to CX And Zero To AX
PUSH DI ; Preserve DI from certain ruin
IF @Datasize EQ 1 ;
LES DI,flagword ; Get the base address for large data
ELSE
MOV DI,flagword ; for small data get the address
ENDIF
REP STOSB ; Zero the bytes (See assumption)
POP DI ; Return DI to prior state
@@: RET ; Return to user program
flgzero ENDP ; Epilogue
END ; Epitaph